let visitModule=(function(){
<<<<<<< HEAD
	let visitId=null,
		$visitTime=$('.visitTime'),
		$visitText=$('.visitText'),
		$submit = $('.submit')
    async function queryBasevisitInfo(){
        let result = await axios.get('/visit/list', {
			params: {
				customerId:visitId

			}
		});
		if (result.code == 0) {
			result = result.data;
			$username.val(result.name);
			result.sex == 0 ? $man.prop('checked', true) : $woman.prop('checked', true);
			$useremail.val(result.email);
			$userphone.val(result.phone);
            $userqq.val(result.QQ);
            $userweixin.val(result.weixin);
			$userType.val(result.type);
			$userdesc.val(result.address);
			return;
		}
		alert(`小主，当前要编辑的员工不存在，请查证！`);

		// visitId = null;
	}
	
	async function submitHandle(){

		let params={
			visitTime:$visitTime.val(),
			visitText:$visitText.val(),
			customerId:visitId
		}

		let res=await axios.post('/visit/add',params)
		if (res.code == 0) {
			alert('小主，您很棒，奴家已经成功为您新增一条数据~~');
			
			return;
		}
		alert('小主，当前网络繁忙，请您刷新后重试~~');

	}


    return {
        init(){
            let params = window.location.href.queryURLParams();
            if (params.hasOwnProperty('id')) {
				visitId = params.id;
				queryBasevisitInfo();
			}


			// 点击提交按钮
			$submit.click(submitHandle);

        }
    }
})()
visitModule.init()